# https://mirrors.pku.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
curl -o miniconda.sh https://mirrors.pku.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash miniconda.sh


conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.pku.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

# conda update -n base -c defaults conda
# conda update --all
conda create -n myenv python=3.11 -y
conda info --envs
conda activate myenv
# deactivate myenv # 退出环境
# conda remove -n 环境名 --all #删除环境
conda install numpy pandas matplotlib scikit-learn

pip uninstall torch torchvision torchaudio

# pytorch 2.1 GPU版本
# libcublas >=12.1.0.26,<12.1.3.1 , which does not exist (perhaps a missing channel)

# wget wget https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda_12.6.1_560.35.03_linux.run

## 在镜像下载
# conda install pytorch torchvision cudatoolkit=10.0
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -- default-timeout=1000
# conda install pytorch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 pytorch-cuda=12.1
##在官网下载
# conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
# conda install pytorch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 pytorch-cuda=12.1 -c pytorch -c nvidia


pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.cache-dir /data/pipcache
python -m pip install --upgrade pip
# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

pip install modelscope

# 查看是否成功
python
import torch
print(torch.cuda.is_available())

## 多卡启动
# CUDA_VISIBLE_DEVICES=0,1 python train.py